﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using PMQLNhaHang.CustomControl;
using QLNHBUS;
using QLNHDAO;

namespace PMQLNhaHang
{
    public partial class fmQLThucDon : Form
    {
        public fmQLThucDon()
        {
            InitializeComponent();
        }

        private void btnThemNhom_Click(object sender, EventArgs e)
        {
            fmQLThucDonNhomMonAn nma = new fmQLThucDonNhomMonAn();
            nma.ShowDialog();
        }

        private void btnXoaNhom_Click(object sender, EventArgs e)
        {

        }

        private void btnSuaNhom_Click(object sender, EventArgs e)
        {

        }

        private void btnThemThucDon_Click(object sender, EventArgs e)
        {
            fmQLThucDonMonAn fmTDMA = new fmQLThucDonMonAn();
            fmTDMA.ShowDialog();
        }

        private void btnXoaThucDon_Click(object sender, EventArgs e)
        {

        }

        private void btnSuaThucDon_Click(object sender, EventArgs e)
        {

        }

        private void fmQLThucDon_Load(object sender, EventArgs e)
        {
            TheHienDanhSachNhomMonAn();
        }
        #region Phương thức xử lý
        private void TheHienDanhSachNhomMonAn()
        {
            List<NhomMonAn> dsNhomMonAn = NhomMonAnBUS.LayDanhSachNhomMonAn();
            var rm = new ResourceManager(typeof(exListBox));
            var img = (Image)rm.GetObject("Table_icon");
            foreach (NhomMonAn t in dsNhomMonAn)
            {
                string detail = t.MaNhomMonAn.ToString(CultureInfo.InvariantCulture);
                var ex = new exListBoxItem(t.MaNhomMonAn, t.Ten, detail, img);
                exlbNhomMonAn.Items.Add(ex);
            }
        }
        #endregion

        private void exlbNhomMonAn_SelectedIndexChanged(object sender, EventArgs e)
        {
            var sel = (exListBoxItem)exlbNhomMonAn.SelectedItem;
            var dsBanAn = BanAnBUS.LayDanhSachBanAn(sel.Id);
            var dsmonan = MonAnBUS.LayDanhSachMonAn(sel.Id);
            dataGridView1.DataSource = dsmonan;
        }
    }
}
